package org.dr.st_docker.resource.ApplicationContext;


import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.core.io.Resource;

public class Demo1 {

    public static void main(String[] args) {
        /*
         * 通过搜索文件系统路径下的xml文件创建ApplicationContext，
         * 但通过指定classpath:前缀强制搜索类加载路径
         * classpath:bean.xml
         * */
        ApplicationContext ctx =
                new ClassPathXmlApplicationContext("classpath:/bean/collectionBean.xml");
        System.out.println(ctx);
        Resource resource = ctx.getResource("keystore.jks");
        System.out.println(resource.getFilename());
        System.out.println(resource.getDescription());
        /**
         * classpath:/bean/collectionBean.xml和
         * classpath*:collectionBean.xml加载效果一致：classpath*作用：所有符合给定名称的classpath资源必须被获取
         * 如果classpath:collectionBean.xml，则显示加载失败找不到文件
         */
        ApplicationContext ctx1 = new ClassPathXmlApplicationContext("classpath*:collectionBean.xml");
        System.out.println(ctx1);


        ApplicationContext ctx3 = new ClassPathXmlApplicationContext("classpath:bean*.xml");
        System.out.println(ctx3);


        ApplicationContext ctx4 = new ClassPathXmlApplicationContext("classpath*:bean*.xml");
        System.out.println(ctx4);

    }
}

